<template>
    <a-form layout='vertical'>
        <a-form-item label="角色名称"
        >
            <a-input v-model="form.roleName"></a-input>
        </a-form-item>

        <a-form-item label="角色描述"
        >
            <a-input v-model="form.roleDesc"></a-input>
        </a-form-item>

    </a-form>
</template>

<script>
    import {Form, DatePicker,Input,Button,Icon,Radio,TreeSelect,message} from 'ant-design-vue';

    export default {
        name: "RoleAdd",
        components: {
            ARadioButton:Radio.Button,
            ARadioGroup:Radio.Group,
            AFormItem:Form.Item,
            AForm:Form,
            ADatePicker:DatePicker,
            AInput:Input,
            AButton:Button,
            AIcon:Icon,
            ATreeSelect:TreeSelect
        },
        data(){

            return {
                form:{
                    roleName:'',
                    roleDesc:''
                }
            };
        },
        methods:{

            submitData(){

                if(this.form.roleName == ''){
                    message.error('请输入角色名称');
                    return;
                }

                this.$axios.post("/auth/role/addRole",this.form).then(d=>{

                    let result = d.data;

                    if(result.status == 0){
                        message.success('添加成功');
                        this.$emit("ok");

                    }else if(result.status == -1){
                        message.error('添加失败，角色已存在');
                    }else{
                        message.error('添加失败');
                    }
                })
                    .catch(e=>{
                        message.error('添加失败,未知错误');
                    })


            }
        }
    }
</script>

<style scoped>

</style>